package de.dlrg.wms.gui.forms.generic;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;

import swing2swt.layout.BorderLayout;

public abstract class AbstractTableViewWithDeleteEdit extends AbstractTableView {
	protected Composite btnBar;
	
	protected abstract void editPressed();
	protected abstract void deletePressed();
	
	
	
	public AbstractTableViewWithDeleteEdit(Composite arg0, int arg1) {
		super(arg0, arg1);
		btnBar = new Composite(this, SWT.NONE);
		btnBar.setLayoutData(BorderLayout.NORTH);
		btnBar.setLayout(new FormLayout());
		
		Button btnDelete = new Button(btnBar, SWT.NONE);
		btnDelete.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent arg0) {
				deletePressed();
			}
		});
		FormData fd_btnDelete = new FormData();
		fd_btnDelete.top = new FormAttachment(0, 10);
		fd_btnDelete.right = new FormAttachment(100);
		btnDelete.setLayoutData(fd_btnDelete);
		btnDelete.setText("Delete");
		
		Button btnEdit = new Button(btnBar, SWT.NONE);
		btnEdit.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent arg0) {
				editPressed();
			}
		});
		FormData fd_btnEdit = new FormData();
		fd_btnEdit.top = new FormAttachment(btnDelete, 0, SWT.TOP);
		fd_btnEdit.right = new FormAttachment(btnDelete, -6);
		btnEdit.setLayoutData(fd_btnEdit);
		btnEdit.setText("Edit");
		
	}
	
	protected void initGUI(final Shell shell) {
		this.shell = shell;

		super.initGUI(shell);
	}
}